// 从本地获取用户名并显示
document.querySelector('.user span').innerHTML = localStorage.getItem('username')

// 退出按钮点击事件
document.querySelector('.logout').addEventListener('click', () => {
    localStorage.removeItem('username');
    localStorage.removeItem('myToken');
    location.href = './login.html'
})

// 初始化数据按钮点击事件
document.querySelector('.init').addEventListener('click', async() => {
    const res = await axios({
        url: 'init/data'
    })
    console.log(res);
    res.data.code == '0' ? Toast.success('恭喜您，初始化数据成功！') && location.reload() : Toast.info(res.data.message)
})